import 'package:flame/game.dart';
import 'package:flame/components.dart';
import 'package:flame/collisions.dart';
import 'package:flutterabc/PlayerComponent.dart';

class CollidableObject extends PositionComponent with CollisionCallbacks {
  CollidableObject(double x, double y, double width, double height) {
    this.position = Vector2(x, y);
    this.size = Vector2(width, height);
    add(RectangleHitbox());
  }

  @override
  void onCollision(Set<Vector2> intersectionPoints, PositionComponent other) {
    super.onCollision(intersectionPoints, other);
    //print('Collided with $other');
    if(other is PlayerComponent){
      print('Collided with $other');
      other.stop();
    }
  }
}